package q1.project.core.exception;

/** 业务异常 用于业务逻辑中的异常情况，会被全局异常处理器捕获并返回给前端 */
public class BusinessException extends RuntimeException {

  private Integer code;

  /** 默认构造函数（错误码为1） */
  public BusinessException(String message) {
    super(message);
    this.code = 1;
  }

  /** 带错误码的构造函数 */
  public BusinessException(Integer code, String message) {
    super(message);
    this.code = code;
  }

  /** 带原因的构造函数 */
  public BusinessException(String message, Throwable cause) {
    super(message, cause);
    this.code = 1;
  }

  /** 带错误码和原因的构造函数 */
  public BusinessException(Integer code, String message, Throwable cause) {
    super(message, cause);
    this.code = code;
  }

  public Integer getCode() {
    return code;
  }

  public void setCode(Integer code) {
    this.code = code;
  }
}
